package com.chinadci.smartcommunitysystembackstage.mapper;

import com.chinadci.smartcommunitysystembackstage.entity.ScsFeedback;
import com.chinadci.smartcommunitysystembackstage.entity.ScsUser;
import com.chinadci.smartcommunitysystembackstage.entity.ScsVisitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chinadci.smartcommunitysystembackstage.entity.ScsVisitorType;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Code Duck
 * @since 2021-04-13
 */
public interface ScsVisitorMapper extends BaseMapper<ScsVisitor> {
    //访客记录
    @Select("select * from scs_visitor where v_name like #{name}")
    @Results({
            @Result(id = true,column = "v_id",property = "vId"),
            @Result(column = "v_name",property = "vName"),
            @Result(column = "v_time",property = "vTime"),
            @Result(column = "u_id",property = "user",many =@Many(select = "Select")),
            @Result(column = "vt_id",property = "type",many =@Many(select = "Selects"))
    })
    List<ScsVisitor> Find(String name);

    @Select("select * from scs_user where u_id=#{u_id}")
    List<ScsUser> Select(int id);

    @Select("select * from scs_visitor_type where vt_id=#{u_id}")
    List<ScsVisitorType> Selects(int id);
}
